************************
** Study 2 - Analyses **
************************

* setting directory
cd "C:\Users\bronc\Desktop\"

* load data
clear
use "C:\Users\bronc\Desktop\Study_2_dataset.dta"


** descriptive statistics **
sum ideology_01
tab ideology_01
tab right_vote
tab center_vote
tab left_vote
tab other_vote

sum ag_bias
sum hostile_bias


************************
** Aggregate analyses **
************************

** voting blocs
* rightists
ttest ag_bias==5 if voting_groups==2

* leftists
ttest ag_bias==5 if voting_groups==0

* centrists
ttest ag_bias==5 if voting_groups==1

* others
ttest ag_bias==5 if voting_groups==3

*anova ag_bias ideo_voting_groups
anova ag_bias voting_groups if voting_groups!=3
oneway ag_bias voting_groups if voting_groups!=3, t sch


* Don't know responses
gen dk=1 if ag_bias==.
replace dk=0 if ag_bias!=.
tab dk

* test of difference in DK responses in the three experimental conditions
tab dk condition, chi col  /* p = .361*/
drop dk


**************************
*** Figure 2 - Panel B ***
**************************
twoway lpolyci ag_bias ideology, degree(3) ///
legend(off) scheme(s2mono) graphregion(fcolor(white)) yline(5)


*************************
** Experimental results **
**************************
ttest hostile_bias if condition!=2, by (threat)
oneway hostile_bias threat, t sch

anova hostile_bias threat
anova hostile_bias threat if condition!=2

anova hostile_bias threat if threat!=0
anova hostile_bias threat if threat!=2

* Model 1
reg hostile_bias threat_dummy control, r
outreg2 using Table_1.doc, replace se dec(2) alpha (.002, .02, .1, .2) ///
symbol (***, **, *, +) 
test threat_dummy = control

* Model 2
reg hostile_bias threat_dummy control right_vote age_01 female relig_01 educ_01, r
outreg2 using Table_1.doc, append se dec(2) alpha (.002, .02, .1, .2) ///
symbol (***, **, *, +) 
test threat_dummy = control


************
** RITEST **
************
** THESE ANALYSES WILL TAKE A WHILE... **

* Model 1
ritest threat_dummy _b[threat_dummy], rep(50000) right seed(19145): ///
reg hostile_bias threat_dummy control, r
/*One-tailed p-value of 0.0237 [SE = 0.0007]*/

* Model 2
ritest threat_dummy _b[threat_dummy], rep(50000) right seed(19145): ///
reg hostile_bias threat_dummy control right_vote age_01 female relig_01 educ_01, r
/*One-tailed p-value of 0.0240 [SE = 0.0007]*/



*****************
** RETRODESIGN **
*****************
* Model 1
retrodesign .2998453, se(.1538481) alpha(0.1) df(931) seed(19145)

* Model 2
retrodesign .2944567, se(.152783) alpha(0.1) df(928) seed(19145)


******************************
** Online appendix analyses **
******************************

*******************
** Balance tests **
*******************
* Threat factor according to the voting blocs groups
oneway age threat, t sch /* p = .462*/
oneway ideology threat, t sch /* p = .311*/
tab female threat, chi col /* p = .981*/
tab educ_level threat, chi col /* p = .884*/
tab relig threat, chi col /* p = .312*/
tab voting_groups threat, chi col /* p = .215*/
mlogit threat age female educ_level relig ideology i.voting_groups /* p = .769*/

* Additional balance tests *
* The threat original experimental conditions
oneway age condition, t sch /* p = .595*/
oneway ideology condition, t sch /* p = .715*/
tab female condition, chi col /* p = .786*/
tab educ_level condition, chi col /* p = .698*/
tab relig condition, chi col /* p = .675*/
tab voting_groups condition, chi col /* p = .159*/
mlogit condition age female educ_level relig ideology i.voting_groups /* p = .670*/

* Threat factor according to the ideological self-placement groups
oneway age threat2, t sch /* p = .540*/
oneway ideology threat2, t sch /* p = 397*/
tab female threat2, chi col /* p = .171*/
tab educ_level threat2, chi col /* p = .577*/
tab relig threat2, chi col /* p = .662*/
tab ideo_placement_groups threat2, chi col /* p = .770*/
mlogit threat2 age female educ_level relig /* p = .697*/
mlogit threat2 age female educ_level relig i.ideo_placement_groups /* p = .645*/


*************************
** Manipulation checks **
*************************
* Factual manipulation checks (emotional responses):
tab fmc_correct

* Substantive manipulation checks (emotional responses):
oneway anger threat_dummy, t 
anova anger threat_dummy
oneway concern threat_dummy, t 
anova concern threat_dummy

oneway enthusiasm threat_dummy, t 
anova enthusiasm threat_dummy
oneway satisfaction threat_dummy, t 
anova satisfaction threat_dummy


**********************
** Robustness tests **
**********************

** 1A) Aggregate analyses with the ideological self-placement groups
* rightists
ttest ag_bias==5 if ideo_placement_groups==2

* leftists
ttest ag_bias==5 if ideo_placement_groups==0

* centrists
ttest ag_bias==5 if ideo_placement_groups==1

anova ag_bias ideo_placement_groups
oneway ag_bias ideo_placement_groups, t sch

** 1B) Experimental results **

ttest hostile_bias2 if condition!=2, by (threat2)

* Model 1
reg hostile_bias2 threat_dummy2 control, r
outreg2 using Table_F1.doc, replace se dec(2) alpha (.002, .02, .1, .2) ///
symbol (***, **, *, +) 
test threat_dummy = control

gen rightist=1 if ideo_placement_groups==2
replace rightist=0 if ideo_placement_groups==0 | ideo_placement_groups==1
tab rightist ideo_placement_groups
* Model 2
reg hostile_bias2 threat_dummy2 control rightist age_01 female relig_01 educ_01, r
outreg2 using Table_F1.doc, append se dec(2) alpha (.002, .02, .1, .2) ///
symbol (***, **, *, +) 
test threat_dummy = controls

** RITEST **
* Model 1
ritest threat_dummy2 _b[threat_dummy2], rep(50000) right seed(19145): ///
reg hostile_bias2 threat_dummy2 control, r
/*One-tailed p-value of 0.0612 [SE = 0.0011]*/

* Model 2
ritest threat_dummy2 _b[threat_dummy2], rep(50000) right seed(19145): ///
reg hostile_bias2 threat_dummy2 control rightist age_01 female relig_01 educ_01, r
/*One-tailed p-value of 0.0579 [SE = 0.0010]*/
drop rightist


** 2) Analyses w/o respondents who failed the factual MC **
* Table 1 - Model 1
reg hostile_bias threat_dummy if fmc==1, r
outreg2 using Table_F2.doc, replace se dec(2) alpha (.002, .02, .1, .2) ///
symbol (***, **, *, +) 

* Table 1 - Model 2
reg hostile_bias threat_dummy right_vote age_01 female relig_01 ///
educ_01 if fmc==1, r
outreg2 using Table_F2.doc, append se dec(2) alpha (.002, .02, .1, .2) ///
symbol (***, **, *, +) 

** RITEST **
* Model 1
ritest threat_dummy _b[threat_dummy], rep(50000) right seed(19145): ///
reg hostile_bias threat_dummy if fmc==1, r
/*One-tailed p-value of 0.0214 [SE = 0.0006]*/

* Model 2
ritest threat_dummy _b[threat_dummy], rep(50000) right seed(19145): ///
reg hostile_bias threat_dummy right_vote age_01 female relig_01 educ_01 if fmc==1, r
/*One-tailed p-value of 0.0280 [SE = 0.0007]*/


** 3) Analyses w/o Israel Bei'tenu voters **
sum ideology if vote_intention==8
sum ag_bias if vote_intention==8

* Table 1 - Model 1
reg hostile_bias threat_dummy control if vote_intention!=8, r
outreg2 using Table_F3.doc, replace se dec(2) alpha (.002, .02, .1, .2) ///
symbol (***, **, *, +) 

* Table 1 - Model 2
reg hostile_bias threat_dummy control right_vote age_01 female relig_01 ///
educ_01 if vote_intention!=8, r
outreg2 using Table_F3.doc, append se dec(2) alpha (.002, .02, .1, .2) ///
symbol (***, **, *, +) 

** RITEST **
* Model 1
ritest threat_dummy _b[threat_dummy], rep(50000) right seed(19145): ///
reg hostile_bias threat_dummy control if vote_intention!=8, r
/*One-tailed p-value of 0.0292 [SE = 0.0008]*/

* Model 2
ritest threat_dummy _b[threat_dummy], rep(50000) right seed(19145): ///
reg hostile_bias threat_dummy control right_vote age_01 female relig_01 educ_01 if vote_intention!=8, r
/*One-tailed p-value of 0.0223 [SE = 0.0007]*/


** 4) Interaction b/w the ingroup-threat condition and right-wing voters **
reg hostile_bias i.threat_dummy##i.right_vote control age_01 female relig_01 educ_01, r
outreg2 using Table_F4.doc, replace se dec(2) alpha (.002, .02, .1, .2) ///
symbol (***, **, *, +) 

* Interactions b/w the two conditions and right-wing voters (resuts not shown) **
reg hostile_bias i.threat_dummy##i.right_vote i.control##i.right_vote ///
age_01 female relig_01 educ_01, r
/* The coef of threatXright-wing = 0.024 (p=0.469) */ 


*****************
*** Figure F1 ***
*****************
/*
label define right_label 0 "Leftist/Centrist voters" 1 "Right-wing Voters"
label values right_vote right_label
*/

ssc install cibar /* if needed... */
cibar hostile_bias, over1(threat) over2(right_vote) level(90) barcol(black gs14 gs9) 
